package com.ysd.Servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.ChanPinXiangQingDaoimpl;
import com.ysd.dao.impl.ChuangShiRenDaoimpl;
import com.ysd.dao.impl.FeiLeiBiaoIdDaoImpl;
import com.ysd.dao.impl.FenLeiBiaoDaoimpl;
import com.ysd.entity.ChanPinXiangQing;
import com.ysd.entity.ChuangShiRen;
import com.ysd.entity.FenLeiBiao;

/**
 * Servlet implementation class ProductDetailServlet
 */
public class ProductDetailServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		ChuangShiRenDaoimpl csrd=new ChuangShiRenDaoimpl();//获得创始人的实现类
		ArrayList<ChuangShiRen> csr=csrd.getChuagShiRen();//获得喜洋洋超市的实现类打点获得喜洋洋超市的表
		request.setAttribute("csr", csr);//存数据到下个页面
		
		
		
		ChanPinXiangQingDaoimpl cpxqd=new ChanPinXiangQingDaoimpl();//获得通过chanPingId查询产品详情的实现类
		int chanPingId=Integer.parseInt(request.getParameter("chanPingId"));//获得前台传来的数据
		ArrayList<ChanPinXiangQing> cpxq=cpxqd.getChanPinXiangQing(chanPingId);//获得通过chanPingId查询产品详情的实现类的数据
		request.setAttribute("cpxq", cpxq);//存数据到下个页面
		
		FenLeiBiaoDaoimpl flbd=new FenLeiBiaoDaoimpl();//获得分类表的实现类
		ArrayList<FenLeiBiao> flb=flbd.getFenLeiBiao(); //获得分类表的实现类打点获得分类表的表
		request.setAttribute("flb", flb);//存数据到下个页面
		

		int id=Integer.parseInt(request.getParameter("chanPinId"));
		FeiLeiBiaoIdDaoImpl flbId=new FeiLeiBiaoIdDaoImpl();//获得通过分类表的chanpinId查询类别的实现类
		ArrayList<FenLeiBiao> lflbId=flbId.getFenLeiBiao(id);//获得前台传来的数据和    31行
		request.setAttribute("id", id);
		request.setAttribute("lflbId", lflbId);
		
		request.getRequestDispatcher("productdetails.jsp").forward(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
